home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Magazine / C_Tutorial / Part-9 / wb1 / screen.c < prev    next >
C/C++ Source or Header  |  1997-10-27  |  1KB  |  48 lines

  1. /* Open screen and setup GadTools stuff */
  2. #include "screen.h"
  3.  
  4. #include<stdio.h>
  5.  
  6. #include<clib/intuition_protos.h>
  7.  
  8. #define MY_TITLE "Hello World Painter"
  9.  
  10. /* Global record of our screen */
  11. struct Screen* screen = NULL;
  12.  
  13. int openScreen(UBYTE depth, UWORD width, UWORD height, ULONG displayid)
  14. {
  15.     UWORD pens[] = { ~0 };
  16.     /* Try to open a new screen with requested properties */
  17.     /* (A parameter of zero will be ignored, so the default */
  18.     /* value will be used by the screen) */
  19.     if(screen = OpenScreenTags(NULL,
  20.                                                         depth ?        SA_Depth : TAG_IGNORE,                depth,
  21.                                                         width ?        SA_Width : TAG_IGNORE,                width,
  22.                                                         height ?    SA_Height : TAG_IGNORE,                height,
  23.                                                         displayid ? SA_DisplayID : TAG_IGNORE,    displayid,
  24.                                                         /* Enable 3D look by specifying SA_Pens */
  25.                                                         SA_Pens,    pens,
  26.                                                         SA_Title,    MY_TITLE,
  27.                                                         TAG_DONE))
  28.         return TRUE;
  29.     else
  30.         printf("Error: could not create screen\n");
  31.     return FALSE;
  32. }
  33.  
  34. void closeScreen()
  35. {
  36.     if(screen)
  37.     {
  38.         CloseScreen(screen);
  39.         /* Set to NULL to indicate that it's been closed */
  40.         screen = NULL;
  41.     }
  42. }
  43.  
  44. struct Screen* getScreen()
  45. {
  46.     return screen;
  47. }
  48.